creating object parameters in {}?

Posted by RealityDysfunction on Programmers See other posts from Programmers or by RealityDysfunction
Published on 2012-10-29T05:26:36Z Indexed on 2012/10/29 11:17 UTC
Read the original article Hit count: 286

Filed under:

I am trying to decode a piece of code from a book:

List<Person> people = new List<Person>()
{
new Person {FirstName="Homer",LastName="Simpson",Age=47},
new Person {FirstName="Marge",LastName="Simpson",Age=45}
};

Person is just a simple class they made, with a bunch of fields: Name, Last Name, etc...

What I don't understand is, don't we send parameters to a constructor of Person in non-curly brackets? I tried replicating this code, but it doesn't seem to fly, any takers?

Thanks for input.

© Programmers or respective owner

Related posts about c#